package com.zhuozhou.jdyc.main.meinfo.adapter;

import android.content.Context;

import com.zhuozhou.jdyc.R;
import com.zhuozhou.jdyc.base.BaseRecyclerViewAdapter;
import com.zhuozhou.jdyc.base.BaseViewHolder;
import com.zhuozhou.jdyc.databinding.AdapterAddressBinding;
import com.zhuozhou.jdyc.main.meinfo.bean.ShippingAddressBean;

/**
 * Create by Once_ChuXy on 2021/10/5
 * Describe:
 */
public class AddressAdapter extends BaseRecyclerViewAdapter<ShippingAddressBean.ArrayBean, AdapterAddressBinding> {
    public OnItemButtonClickListener mOnItemButtonClickListener;
    public OnItemDelClickListener mOnItemDelClickListener;

    public AddressAdapter(Context context) {
        super(context);
    }

    @Override
    public void onBindViewHolder(BaseViewHolder baseViewHolder, int pos) {
        super.onBindViewHolder(baseViewHolder, pos);
    }

    @Override
    public void onBindHolder(BaseViewHolder<AdapterAddressBinding> holder, int pos) {
        holder.getBinding().setBean(mList.get(pos));
        holder.getBinding().compile.setOnClickListener(v -> {
            if (mOnItemButtonClickListener != null) {
                mOnItemButtonClickListener.OnItemButtonClick(mList.get(pos));
            }
        });
        holder.getBinding().tvDelete.setOnClickListener(v -> {
            if (mOnItemDelClickListener != null) {
                mOnItemDelClickListener.OnItemDelClick(mList.get(pos));
            }
        });
        holder.getBinding().llLocation.setOnClickListener(v -> {
            if (mOnItemClickListener != null) {
                mOnItemClickListener.onItemClick(v, pos);
            }
        });
    }

    @Override
    protected int getLayoutId() {
        return R.layout.adapter_address;
    }//编辑

    public void setOnItemButtonClickListener(OnItemButtonClickListener l) {
        mOnItemButtonClickListener = l;
    }

    public interface OnItemButtonClickListener {
        void OnItemButtonClick(ShippingAddressBean.ArrayBean bean);
    }

    public void setOnItemDelClickListener(OnItemDelClickListener l) {
        mOnItemDelClickListener = l;
    }

    public interface OnItemDelClickListener {
        void OnItemDelClick(ShippingAddressBean.ArrayBean bean);
    }

}
